{# SETTINGS #}
{% set element = element|default('article') %}
{% set headline__element = headline__element|default('h2') %}
{% if url is not empty %}
  {% set attributes = attributes.setAttribute('href', url) %}
  {% set element = 'a' %}
{% endif %}

{# CARD CLASSES #}
{% set image_classes = ([
  alignment == 'center'?'justify-content-center': '',
  'd-flex',
]) | sort | join(' ') | trim %}

{% set link_classes = ([
  alignment == 'center'?'mx-auto': '',
]) | sort | join(' ') | trim %}

{% set classes = ([
  alignment == 'center' ? 'text-center',
  'card mb-4 mb-lg-0',
] | sort | join(' ') | trim ) %}

{% set attributes = attributes|default(create_attribute()).addClass(classes) %}

{# TEMPLATE #}
<{{ element }} {{ attributes }}>
  {% if image is not empty %}
    {% block image %}
      <div class="card-img-top">
        {{ image }}
      </div>
    {% endblock %}
  {% endif %}
  <div class="card-body">
    <div class="card-subtitle mb-2 text-muted">
      {% block preheadline %}
        {{ preheadline }}
      {% endblock %}
    </div>
    <h2 class="card-title">
      {% block headline %}
        {{ headline }}
      {% endblock %}
    </h2>
    <p class="card-text">
      {% block text %}
        {{ text }}
      {% endblock %}
    </p>
  </div>
</{{ element }}>
